[TAS-4569] ✨ Support color mode#635
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive color mode (light/dark/system) support to the 3ook.com application. The implementation includes user preference storage, UI components for switching modes, and extensive styling updates across pages and components to support dark mode.
Changes:
- Added color mode type definitions and user settings integration for persisting user preferences
- Enabled Nuxt UI color mode with light as default, and created a composable to sync color mode with user settings
- Updated CSS with dark mode variants, replacing hardcoded colors with semantic color classes (text-highlighted, text-muted, text-dimmed, bg-accented)
- Added ColorModeSwitcher component and integrated it into the account settings page
- Applied dark mode styling across all major pages (store, reader, checkout, account, about) and components
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| shared/types/user-settings.d.ts | Added ColorMode type and colorMode field to user settings |
| nuxt.config.ts | Enabled Nuxt UI color mode with custom storage key and light default |
| composables/use-color-mode-sync.ts | New composable to synchronize color mode between Nuxt and user settings |
| components/ColorModeSwitcher.vue | New component for selecting color mode (light/dark/system) |
| assets/css/main.css | Added dark mode CSS variables and moved highlighted text color into mode-specific rules |
| app.config.ts | Updated UI component theme with dark mode ring colors |
| pages/store/index.vue | Updated tag button hover states with dark mode variants |
| pages/store/claim.vue | Replaced gray-600 with semantic text-muted class |
| pages/store/[nftClassId]/index.vue | Updated text colors and backgrounds to support dark mode throughout product page |
| pages/reader/epub.vue | Added dark mode support to epub reader with background and text color changes, updated UI controls |
| pages/plus/success.vue | Replaced hardcoded green and gray colors with semantic theme colors |
| pages/list.vue | Updated heading color to use theme-cyan |
| pages/checkout.vue | Replaced hardcoded colors with semantic classes throughout checkout flow |
| pages/account/index.vue | Added ColorModeSwitcher to account settings |
| pages/about.vue | Updated text colors to use semantic text-muted class |
| components/* | Updated various components with dark mode support using semantic color classes |
| i18n/locales/*.json | Added translations for color mode labels and reordered some keys |
244887e to
07df180
Compare
07df180 to
9756fcb
Compare
9756fcb to
97a3557
Compare
97a3557 to
b8e59ab
Compare
b8e59ab to
6541ce6
Compare
8b1b0a9 to
a11d502
Compare
| if (settingsEntry.value?.data) { | ||
| (settingsEntry.value.data as Record<string, unknown>)[key] = value | ||
| } |
There was a problem hiding this comment.
The immediate update of settingsEntry.value.data in queueUpdate creates a potential race condition. If the API call fails, the local state will be out of sync with the server. Consider whether this optimistic update is necessary, or if a rollback mechanism should be added to revert the change on API failure.
a11d502 to
83d7788
Compare
83d7788 to
731b79a
Compare
| definePageMeta({ layout: false }) | ||
| definePageMeta({ | ||
| layout: false, | ||
| colorMode: 'light', |
There was a problem hiding this comment.
Dont want to waste time on tuning the about page for dark mode
| @@ -0,0 +1,64 @@ | |||
| export function useColorModeSync() { | |||
There was a problem hiding this comment.
The ColorMode type is used but not imported. This file needs to import ColorMode from the shared types to avoid TypeScript errors.
| import type { UserSettingKey } from '~/shared/types/user-settings' | ||
|
|
||
| const ALLOWED_KEYS = ['locale', 'currency'] as const satisfies readonly UserSettingKey[] | ||
| const ALLOWED_KEYS = ['locale', 'currency', 'colorMode'] as const satisfies readonly UserSettingKey[] |
There was a problem hiding this comment.
UserSettingKey is used on line 1 and 15 but is not imported. This will cause a TypeScript error. Add the import statement at the top of the file.
| const selectedColorMode = computed(() => preference.value) | ||
|
|
||
| function handleColorModeChange(value: string) { | ||
| preference.value = value as ColorMode |
There was a problem hiding this comment.
ColorMode type is used on line 34 but is not imported. This will cause a TypeScript error. Add the import for ColorMode from shared types.
No description provided.